#ifndef VSMATERIALPASS_H
#define VSMATERIALPASS_H
#include "VSPShader.h"
#include "VSVShader.h"
#include "VSMatrix3X3W.h"
#include "VSPass.h"
#include "VSShaderMap.h"
namespace VSEngine2
{
	class VSMaterialInstance;
	class VSGRAPHIC_API VSMaterialPass : public VSPass
	{
		//RTTI
		DECLARE_RTTI;
		//PRIORITY
		
	public:
		VSMaterialPass();
		virtual ~VSMaterialPass();
	public:

		inline void SetMaterialInstance(VSMaterialInstance * pMaterialInstance)
		{
			m_pMaterialInstance = pMaterialInstance;
		}
		inline void AddLight(VSLight * pLight)
		{
			if (pLight)
			{
				for (unsigned int i = 0 ; i < m_Light.GetNum() ;i++)
				{
					if (m_Light[i] == pLight)
					{
						return ;
					}
				}
				m_Light.AddElement(pLight);
			}
		}
		
		virtual unsigned int GetPassType()
		{
			return PT_MATERIAL;
		}
	protected:
		VSMaterialInstance * m_pMaterialInstance;
		VSArray<VSLightPtr> m_Light;

		

		bool GetVShader();
		bool GetPShader();
	public:
		
	public:
		static bool RegisterMainFactory();
	private:
		static bool InitialClassFactory();	
		static VSObject * FactoryFunc();
		static bool ms_bRegisterMainFactory;

	public:
		virtual bool Draw(VSRenderer * pRenderer);

		VSShaderSet * m_pVShaderSet;
		VSShaderKey m_VShaderkey;

		VSShaderSet * m_pPShaderSet;
		VSShaderKey m_PShaderkey;
	};
	typedef VSPointer<VSMaterialPass> VSMaterialPassPtr;
}
#endif